function login ()
{
    //1. 获取输入框内容
    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;
    console.log('username:'+username+'password:'+password);

    //2. 创建ajax对象
    var ajax = getAjax();
    ajax.open('post','/login/click',true);

    //3. 监听状态变化
    ajax.onreadystatechange = function ()
    {
        if (ajax.readyState == 4 && ajax.status == 200)
        {
            console.log('登录成功');
        }
    }

    //4. 准备参数,发送请求
    ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    var params = "username="+username + "&password="+password;
    ajax.send(params);

}

function getAjax()
{

    var ajax = null;
    try
    {
        ajax = new XMLHttpRequest();
    }catch (e)
    {
        ajax = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return ajax;
}